package com.training.action.xixiaoming;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.training.pojo.chengshu.MotorRoom;
import com.training.pojo.chengshu.UDept;
import com.training.pojo.chengshu.UUser;
import com.training.service.xixiaoming.deptService;
import com.training.service.xixiaoming.empService;
import com.training.service.xixiaoming.motorService;

public class listMotorAction extends ActionSupport{
	
	private motorService motorser;
	List<MotorRoom> listmotor;
	private static final Integer MAX = 3;
	private Integer page = 1;
	private Integer totalPages;
	
	private deptService deptser;
	private empService empser;
	
	private List<UDept> deptlist;
	private List<UUser> emplist;
	
	public String execute(){
		
		deptlist=deptser.getAllDept();
		emplist=empser.getAllEmp();
		
		int rowCount = motorser.getRowCount();
		totalPages = ((rowCount % MAX) == 0)?(rowCount/MAX):(rowCount/MAX + 1);
		if(page < 1){
			page = 1;
		}
		if(page > totalPages){
			page = totalPages;
		}
		int start = (page - 1) * MAX+1;
		listmotor=motorser.listMotor(start,MAX);
		return "success";
	}

	public List<MotorRoom> getListmotor() {
		return listmotor;
	}

	public void setListmotor(List<MotorRoom> listmotor) {
		this.listmotor = listmotor;
	}

	public motorService getMotorser() {
		return motorser;
	}

	public void setMotorser(motorService motorser) {
		this.motorser = motorser;
	}

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(Integer totalPages) {
		this.totalPages = totalPages;
	}

	public static Integer getMax() {
		return MAX;
	}

	public List<UDept> getDeptlist() {
		return deptlist;
	}

	public void setDeptlist(List<UDept> deptlist) {
		this.deptlist = deptlist;
	}

	public List<UUser> getEmplist() {
		return emplist;
	}

	public deptService getDeptser() {
		return deptser;
	}

	public void setDeptser(deptService deptser) {
		this.deptser = deptser;
	}

	public empService getEmpser() {
		return empser;
	}

	public void setEmpser(empService empser) {
		this.empser = empser;
	}

	public void setEmplist(List<UUser> emplist) {
		this.emplist = emplist;
	}
	
	

}
